function [CF2, Cm3] = FourierF2(UT, AF2, Am3)
%
% Fourier Time Series for F2-Layer
%
%DESCRIPTION:
%This function computes the Fourier time series for foF2 and M(3000)F2.
%
%PROTOTYPE:
% [CF2, Cm3] = FourierF2(UT, AF2, Am3)
%
%--------------------------------------------------------------------------
% INPUTS:
%   UT         [1x1]       Universal Time            [hours]
%   AF2        [76x13]     Interp. Coeff.s for foF2  [-]
%   Am3        [49x9]      Int. Coef.s for M(3000)F2 [-]
%--------------------------------------------------------------------------
% OUTPUTS:
%   CF2        [76x1]      Coeff.s for foF2          [-]
%   Cm3        [49x1]      Coeff.s for M(3000)F2     [-]
%--------------------------------------------------------------------------
%
%NOTES:
% - The outputs are vectors of coefficients for Legendre calculation for
%   foF2 and M(3000)F2.
%
%CALLED FUNCTIONS:
% (none)
%
%UPDATES:
% (none)
%
%REFERENCES:
% [1] "Ionospheric Correction Algorithm for Galileo Single-Frequency Users"
%      - European GNSS (Galileo) Open Service
% [2] "Electron Density Models and Data for Transionospheric Radio
%      Propagation" - Report ITU-R P.2297-1 (05/2019)
%
%AUTHOR(s):
%Luigi De Maria, Matteo D'Addazio, 2022
%

%% Main Code

%Constants
DR = pi/180;                %Conversion Factor: deg->rad

%Memory Pre-Allocation
CF2 = zeros(76,1);
Cm3 = zeros(49,1);

%Time Argument
T = (15*UT - 180) * DR;

%Computation of Fourier Time Series of CF2
for i = 1 : 76
    aux = 0;
    for k = 1 : 6
        aux = aux + (AF2(i,2*k)*sin(k*T) + AF2(i,2*k+1)*cos(k*T));
    end
    CF2(i) = AF2(i,1) + aux;
end

%Computation of Fourier Time Series of M(3000)F2
for i = 1 : 49
    aux = 0;
    for k = 1 : 4
        aux = aux + (Am3(i,2*k)*sin(k*T) + Am3(i,2*k+1)*cos(k*T));
    end
    Cm3(i) = Am3(i,1) + aux;
end

end